package com.prestamomo.vil.ppa.pmvilpage.pmfitter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.prestamomo.vil.ppa.R;
import com.prestamomo.vil.ppa.pmvilapi.PmvilSerConfig;

import java.util.List;

public class PmvilSerConfigFiter extends BaseAdapter {

    private Context pmvilCofigCont;
    private List<PmvilSerConfig.ExtInfoArrPmvil> pmvilSerList;

    public PmvilSerConfigFiter(Context pmvilCofigCont, List<PmvilSerConfig.ExtInfoArrPmvil> pmvilSerList) {
        this.pmvilCofigCont = pmvilCofigCont;
        this.pmvilSerList = pmvilSerList;
    }

    @Override
    public int getCount() {
        return pmvilSerList.size();
    }

    @Override
    public Object getItem(int position) {
        return pmvilSerList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ConfigPmvilItemHolde configPmvilItemHolde = null;
        if(convertView==null){
            convertView = LayoutInflater.from(pmvilCofigCont).inflate(R.layout.cofig_pmvil_item_ly, null, false);
            configPmvilItemHolde = new ConfigPmvilItemHolde();
            configPmvilItemHolde.cofigPmvilTvname = convertView.findViewById(R.id.cofig_pmvil_item_tvname);
            convertView.setTag(configPmvilItemHolde);
        }else {
            configPmvilItemHolde = (ConfigPmvilItemHolde) convertView.getTag();
        }

        configPmvilItemHolde.cofigPmvilTvname.setText(pmvilSerList.get(position).getPmvilname());
        return convertView;
    }

    public class ConfigPmvilItemHolde{
        private TextView cofigPmvilTvname;
    }
}
